#include "FoodBuilderSinHamburger.h"
#include "FoodHamburger.h"

#include "UI/ModRun/Output/FactoryOutput.h"

FoodBuilderHamburger::FoodBuilderHamburger(QString strName)
{
    m_strName = strName;
    m_listFood.clear();

    QString strOutput = "汉堡Builder 构造:" + m_strName;
    qDebug() << strOutput;
    std::shared_ptr<IOutput> pOutPut = FactoryOutput::GetInstance()->CreateRunOutput();
    if (pOutPut)
    {
        std::initializer_list<QString> outList{ strOutput };
        pOutPut->OutPut(outList);
    }
}

FoodBuilderHamburger::~FoodBuilderHamburger()
{
    QString strOutput = "汉堡Builder 析构:" + m_strName;
    qDebug() << strOutput;
    std::shared_ptr<IOutput> pOutPut = FactoryOutput::GetInstance()->CreateRunOutput();
    if (pOutPut)
    {
        std::initializer_list<QString> outList{ strOutput };
        pOutPut->OutPut(outList);
    }
}

void FoodBuilderHamburger::CreateFood(size_t uNum)
{
    QString strOutputStart = "汉堡Builder 创建Food开始:" + m_strName + "[" + QString::number(uNum) + "]";
    qDebug() << strOutputStart;
    std::shared_ptr<IOutput> pOutPut = FactoryOutput::GetInstance()->CreateRunOutput();
    if (pOutPut)
    {
        std::initializer_list<QString> outList{ strOutputStart };
        pOutPut->OutPut(outList);
    }
    ///////////////////////////////////////////////////////////////////////////////
    for (size_t i = 0; i < uNum; i++)
    {
        std::shared_ptr<IFood> foodHamburger(new FoodHamburger(m_strName));
        m_listFood.push_back(foodHamburger);
    }
    ///////////////////////////////////////////////////////////////////////////////
    QString strOutputEnd = "汉堡Builder 创建Food结束:" + m_strName + "[" + QString::number(uNum) + "]";
    qDebug() << strOutputEnd;
    if (pOutPut)
    {
        std::initializer_list<QString> outList{ strOutputEnd };
        pOutPut->OutPut(outList);
    }
}

std::list<std::shared_ptr<IFood>> FoodBuilderHamburger::GetFoodItems()
{
    return m_listFood;
}
